/**
 *
 */
import Util;
import OpenApi;

import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  
  @endpointMap = {
    ap-southeast-1 = 'nls-measure.ap-southeast-1.aliyuncs.com',
    cn-hangzhou = 'nls-measure.cn-hangzhou.aliyuncs.com',
    cn-north-2-gov-1 = 'nls-measure-vpc.cn-north-2-gov-1.aliyuncs.com',
    cn-shanghai = 'nls-measure.cn-shanghai.aliyuncs.com',
  };
  checkConfig(config);
  @endpoint = getEndpoint('nls-cloud-measure', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model ListProjectsRequest {
  offset?: int32(name='Offset'),
  pageSize?: int32(name='PageSize'),
  projectId?: int32(name='ProjectId'),
}

model ListProjectsResponseBody = {
  requestId?: string(name='RequestId'),
  data?: string(name='Data'),
}

model ListProjectsResponse = {
  headers: map[string]string(name='headers'),
  body: ListProjectsResponseBody(name='body'),
}

async function listProjectsWithOptions(request: ListProjectsRequest, runtime: Util.RuntimeOptions): ListProjectsResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('ListProjects', '2019-09-05', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function listProjects(request: ListProjectsRequest): ListProjectsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listProjectsWithOptions(request, runtime);
}

model ListAvailableTtsModelsRequest {
  aliyunLang?: string(name='AliyunLang'),
}

model ListAvailableTtsModelsResponseBody = {
  requestId?: string(name='RequestId'),
  data?: string(name='Data'),
}

model ListAvailableTtsModelsResponse = {
  headers: map[string]string(name='headers'),
  body: ListAvailableTtsModelsResponseBody(name='body'),
}

async function listAvailableTtsModelsWithOptions(request: ListAvailableTtsModelsRequest, runtime: Util.RuntimeOptions): ListAvailableTtsModelsResponse {
  Util.validateModel(request);
  var req = new OpenApi.OpenApiRequest{ 
    body = Util.toMap(request),
  };
  return doRPCRequest('ListAvailableTtsModels', '2019-09-05', 'HTTPS', 'POST', 'AK', 'json', req, runtime);
}

async function listAvailableTtsModels(request: ListAvailableTtsModelsRequest): ListAvailableTtsModelsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listAvailableTtsModelsWithOptions(request, runtime);
}

